package com.wlz.bio;

import lombok.extern.slf4j.Slf4j;

import java.net.Socket;
import java.nio.charset.StandardCharsets;

/**
 * @author wlz
 * @date 2022-07-06  9:19 下午
 */
@Slf4j
public class SocketClient {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("localhost", 9000);

        socket.getOutputStream().write("helloworldSocketServer".getBytes(StandardCharsets.UTF_8));

        socket.getOutputStream().flush();

        log.info("向服务端发送消息结束 .....");

        byte[] bytes = new byte[1024];

        socket.getInputStream().read(bytes);
        log.info("接收服务端数据: {}", new String(bytes));

        socket.close();

    }
}
